package cn.tedu.onlinestore.seller.service.serviceimpl;

import cn.tedu.onlinestore.seller.mapper.SellerMapper;
import cn.tedu.onlinestore.seller.pojo.dto.DianPuParam;
import cn.tedu.onlinestore.seller.pojo.entity.Seller;
import cn.tedu.onlinestore.seller.pojo.vo.DianPuVO;
import cn.tedu.onlinestore.seller.service.SellerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
@Slf4j
public class SellerServiceImpl implements SellerService {
    @Autowired
    SellerMapper sellerMapper;

    @Override
    public void addSeller(Seller seller) {
        sellerMapper.addSeller(seller);

    }

    @Override
    public List<Seller> getAllSeller(Integer page, Integer size) {
        log.debug("查询所以店铺业务层");
        return sellerMapper.getAllSeller(page,size);
    }

    @Override
    public DianPuVO selectSellerById(String username) {
        log.debug("查询店铺业务层：{}" ,username);
        DianPuVO dianPuVO= sellerMapper.selectSellerById(username);
        log.debug("查询店铺：{}" ,dianPuVO);
        return dianPuVO;
    }

    @Override
    public void addDP(DianPuParam dianPuParam) {
        log.debug("新增店铺信息业务：{}",dianPuParam);
        sellerMapper.addDP(dianPuParam);
    }

    @Override
    public void updateDP(DianPuParam dianPuParam) {
        log.debug("修改店铺信息业务：{}",dianPuParam);
        Seller seller = new Seller();
        BeanUtils.copyProperties(dianPuParam,seller);
        sellerMapper.updateDP(seller);

    }
}
